package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api("菜品在这里的er")
@RequestMapping("/admin/setmeal")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    @PostMapping("")
    public Result setmealAdd(@RequestBody SetmealDTO setmealDTO) {
        setmealService.setmealAdd(setmealDTO);
        return Result.success();
    }

    @DeleteMapping("")
    public Result deleteSetmeal(@RequestParam List<Long> ids) {
        setmealService.deleteSetmealByIds(ids);
        return Result.success();
    }

    @GetMapping("/{id}")
    public Result<SetmealVO> findById(@PathVariable Long id){
        System.out.printf("--------------------------.>>>>>>>>>>>");
        System.out.printf("idid"+id);
        SetmealVO kk =  setmealService.setmealById(id);
        return Result.success(kk);
    }

    @GetMapping("/page")
    public Result<PageResult> page(SetmealPageQueryDTO ssmpDto){
        PageResult kk = setmealService.pageAll(ssmpDto);
        return Result.success(kk);
    }
    @PostMapping("/status/{status}")
    public Result<String> status(@PathVariable Integer status,Long id){
        setmealService.statusById(status,id);
        return Result.success();
    }

    @PutMapping("")
    public Result updateSetmeal(@RequestBody SetmealVO sstV){
        setmealService.updateSetmealByVo(sstV);

        return Result.success();
    }

}
